﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UID"] != null)
        {
            Banner.Text = "已登录";
        }
        else {
            Banner.Text = "<div class=\"topuser form-wrap\" id=\"Div1\"><a href=\"Login.aspx\" class=\"login left\">登录</a></div>";
        }
        bool Agent=CheckAgent();
        //xsdsd.Text = Agent.ToString;

        if (Agent == false)
        {
            xsdsd.Text = "Not Found 404";
        }
    }

    public static bool CheckAgent()
    {
        bool flag = false;
        string agent = HttpContext.Current.Request.UserAgent;
        string[] keywords = { "Android", "iPhone", "iPod", "iPad", "Windows Phone", "MQQBrowser" };
        //排除 Windows 桌面系统            
        if (!agent.Contains("Windows NT") || (agent.Contains("Windows NT") && agent.Contains("compatible; MSIE 9.0;")))
        {
            //排除 苹果桌面系统                
            if (!agent.Contains("Windows NT") && !agent.Contains("Macintosh"))
            {
                foreach (string item in keywords)
                {
                    if (agent.Contains(item))
                    {
                        flag = true;
                        break;
                    }
                }
            }
            flag = true;
        }
        return flag;
    }

}
